import Cookie from 'js-cookie'

export const setCookie = (key: string, value: any) => {
  if (typeof value === 'object') {
    value = JSON.parse(value)
  }
  Cookie.set(key, value)
}

export const getCookie = (key: string) => {
  const data = (Cookie.get(key)) as string
  try {
    return JSON.parse(data)
  } catch (error) {
    return data
  }
}

export const removeCookie = (key: string) => {
  Cookie.remove(key)
}
